package follow.juc.writing.demo2;

/**
 * @author tu zy
 * @version 1.0
 * @date 2020/12/5 11:38
 */

public class ThreadDemo {
    public static void main(String[] args) {

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {

                for (int i=0;i<5;i++){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(i +"子线程...");
                }
            }
        });

        thread.setDaemon(true);
        System.out.println(thread.getState());
        thread.start();
        System.out.println(thread.getState());



        for (int i=0;i<2;i++){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("主线程"+i);
        }

        System.out.println("主线程执行完毕");
    }
}
